package com.five.community.service.impl;

import com.five.community.bean.Activity;
import com.five.community.bean.Village;
import com.five.community.bean.vo.ActivityVo;
import com.five.community.bean.vo.RepairVo;
import com.five.community.mapper.ActivityMapper;
import com.five.community.service.ActivityService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityServiceImpl implements ActivityService {

    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public List<ActivityVo> selectAll() throws Exception {
        return activityMapper.selectAllF();
    }

    @Override
    public List<ActivityVo> selectByTitle(String title) throws Exception {
        return activityMapper.selectByTitle(title);
    }

    @Override
    public void delete(long id) throws Exception {
        activityMapper.delete(id);
    }

    @Override
    public void insert(Activity activity) throws Exception {
        activityMapper.insert(activity);
    }

    @Override
    public Activity selectById(long id) throws Exception {
        return activityMapper.selectById(id);
    }

    @Override
    public void update(Activity activity) throws Exception {
        activityMapper.update(activity);
    }

    @Override
    public PageInfo<ActivityVo> getPageInfo(int pageNum, int pageSize) throws Exception {
        //先初始化模型在查询信息顺序不能颠倒
        //初始化分页插件模型
        PageHelper.startPage(pageNum,pageSize);
        //查询所有信息获得列表集合
        List<ActivityVo> activityVos = activityMapper.selectAllF();
        //分页模型加入数据
        PageInfo<ActivityVo> pageInfo = new PageInfo<>(activityVos);
        //返回分页模型
        return pageInfo;
    }
}
